package com.zjw.project.meeting.controller;

import com.zjw.entity.po.MeetingPub;
import com.zjw.service.MeetingPubService;
import com.zjw.util.result.ResultCode;
import com.zjw.util.result.ResultJson;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Slf4j
@Controller
@RequestMapping("meetingPub")
public class MeetingPubController {

    @Autowired
    private MeetingPubService meetingPubService;


    @ResponseBody
    @RequestMapping("add")  //meetingPub/add
    public int meetingPub(MeetingPub pub){
        int i = meetingPubService.insertSelective(pub);
        return i;
    }

    /**
     * 根据用户ID 查询 发布的会议列表
     */

    @ResponseBody
    @RequestMapping("uid")   // meetingPub/uid?uid=1
    public Object selectMeetingPubsByUid(@RequestParam("uid")final int uid){
        List<MeetingPub> list= meetingPubService.selectMeetingPubsByUid(uid);
        if(list.size()==0){
            return  new ResultJson<>(null, ResultCode.NOT_DATA);
        }
        return new ResultJson<>(list,ResultCode.SUCCESS);
    }

}
